<?php
/**
 * 获得用户信息动作类
 * @author yaoli<yaoli@pateo.com.cn>
 * @version 1.0 GetUser add by yaoli<yaoli@pateo.com.cn> 
 */
class roadbook_way extends ActionBase {
	
	private $date = null;
	
	function init() {
		$this->date ['page'] = (isset ( $_REQUEST ['page'] )) ? ($_REQUEST ['page'] - 1) : 0;
		
	
	}
	
	/**
	 * 动作
	 *
	 * @see AActionBase::action()
	 */
	
	// 书
	public function action() {
		$this->date ['roadbook'] = load_model ( 'roadbook' )->getRoadbook ( $this->date ['page'] );
		
		$this->date ['count'] = load_model ( 'roadbook' )->getRcount ( );
		
		$this->date ['pagecontent'] = fenye ( url ( 'roadbook/action' ) . "&page=", $this->date ['page'] + 1, $this->date ['count'], PERPAGE );
		
		$this->template ();
		$this->template->assign ( $this->date );
		$this->template->display ( 'roadbook.html' );
	}
	
	// 删除路书 途径地
	public function del() {
		load_model ( 'roadbook_way' )->delTable ( array ('roadbook_id' => $_REQUEST ['roadbook_id'] ,'way_id' => $_REQUEST['way_id']) );
		#$URL = $_SERVER ['HTTP_REFERER'];
		$URL =  url('roadbook/way',array('roadbook_id'=>$_REQUEST ['roadbook_id']));
		header ( "Location: $URL" );
		exit ();
	}
	
	public function modify(){
		$this->date['way_id'] = $_REQUEST['way_id'];
		$this->date['roadbook_id'] = $_REQUEST['roadbook_id'];
		
		$this->date['alert']['str']='';
		$this->date['alert']['color']='';
	
		if(isset($_REQUEST['order'])){
			$count1 = load_model('roadbook_way')->
			replaceTable(array('roadbook_id'=>$_REQUEST['roadbook_id'],'way_id'=>$_REQUEST['way_id'],'order'=>$_REQUEST['order']));
			if($count1>0){
				$this->date['alert']['str']='操作成功！';
				$this->date['alert']['color']='green';
			}else{
				$this->date['alert']['str']='未知错误添加失败！';
				$this->date['alert']['color']='red';
			}
		}
		$roadbook_way=load_model('roadbook_way')->getTable(array('roadbook_id'=>$_REQUEST['roadbook_id'],'way_id'=>$_REQUEST['way_id']));
		$this->date['roadbook_way'] = $roadbook_way[0];
		$this->template ();
		$this->template->assign ( $this->date );
		$this->template->display ( 'roadbook_way_order.html' );
	}
	
	

}
